<?php

/**
 * Cadpessoa form base class.
 *
 * @method Cadpessoa getObject() Returns the current form's model object
 *
 * @package    SCBE
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseCadpessoaForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'idpessoa'       => new sfWidgetFormInputHidden(),
      'cpf'            => new sfWidgetFormInputText(),
      'nome'           => new sfWidgetFormInputText(),
      'datanascimento' => new sfWidgetFormDate(),
      'email'          => new sfWidgetFormInputText(),
      'telefone'       => new sfWidgetFormInputText(),
      'endereco'       => new sfWidgetFormInputText(),
      'idcidade'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Cadcidade'), 'add_empty' => true)),
      'nomepai'        => new sfWidgetFormInputText(),
      'nomemae'        => new sfWidgetFormInputText(),
      'estadocivil'    => new sfWidgetFormInputText(),
      'nomeconjuge'    => new sfWidgetFormInputText(),
      'nacionalidade'  => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'idpessoa'       => new sfValidatorChoice(array('choices' => array($this->getObject()->get('idpessoa')), 'empty_value' => $this->getObject()->get('idpessoa'), 'required' => false)),
      'cpf'            => new sfValidatorString(array('max_length' => 11)),
      'nome'           => new sfValidatorString(array('max_length' => 45)),
      'datanascimento' => new sfValidatorDate(array('required' => false)),
      'email'          => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'telefone'       => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'endereco'       => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'idcidade'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Cadcidade'), 'required' => false)),
      'nomepai'        => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'nomemae'        => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'estadocivil'    => new sfValidatorString(array('max_length' => 1, 'required' => false)),
      'nomeconjuge'    => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'nacionalidade'  => new sfValidatorString(array('max_length' => 1, 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('cadpessoa[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Cadpessoa';
  }

}
